<?php

require_once('simpletest/unit_tester.php');
require_once('simpletest/reporter.php');

require_once('../category.php');

class CategoryTest extends UnitTestCase{
	
	function test_findAllCategoriesIsReturningAllCategories(){
		
		$numberOfCategories = Category::getNumberOfCategories();
		$this->assertEqual($numberOfCategories, sizeof(Category::findAllCategories()));
	}
	
	const CATEGORY_TITLE = "unit test category title ";
	
	function test_addCategoryValidatesUniquenessOfTitle(){
		
		$date = date("Y-m-d H:m:s");
		
		/* this title is entered first, so it can be entered again, and checked
		   for uniqueness
		*/
		Category::addCategory(CategoryTest::CATEGORY_TITLE . $date);
		$this->assertFalse(Category::addCategory(CategoryTest::CATEGORY_TITLE . $date));
	}
	
	//TODO: test addCategory when it is validating presence of name
}
$test = &new CategoryTest();
$test->run(new HtmlReporter());
?>
